/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-04-11
 * Time: 23:26
 */
public class Test1 {
    public static void main(String[] args) {
        Cat cat = new Cat("柚子","雌",2);
        Dog dog = new Dog("球球","雄",1);
        //1.直接复制 子类对象赋值给父类对象
        Animal bird = new Bird("泡芙","雌",2);
        eat(cat);
        eat(dog);
        eat(bird);
    }
    //2.方法传参 形参的类型为Animal父类,可接受任意子类对象,即animal1的类型可以是猫、狗、鸟等子类
    public static void eat(Animal animal1) {
        animal1.eat();
    }
    //3.方法返回 返回任意子类对象
    public static Animal guessAnimal(String name) {
        if("球球".equals(name)) {
            return new Dog("球球","雄",1);
        }
        return null;
    }

}
